<template>
    <div class="echart-chart" v-if="isHouseTypeShow">
        <div class="inside">
            <header><i class="el-icon-location-outline"></i> 多家庭公寓中位租金同比环比增幅</header>
            <div class="chartBox clearfix" style="min-height: 100px;">
                <aside v-show="!chartNoDataShow">
                    <p>环比：{{ isNull0(mom) }}</p>
                    <p>同比：{{ isNull0(yoy) }}</p>
                    <p>季度环比增幅：{{ isNull0(qoq) }}</p>
                    <p>平均每月租金：{{ isNull0_USD(zri) }}</p>
                    <!--<p>租金采样个数——zri_record_cnt：{{ isNull0(zri_record_cnt) }}</p>-->
                </aside>
                <h4 ref="Zip_Zri_MultiFamilyResidenceRental_Summary_NoData" v-show="chartNoDataShow"></h4>
            </div>
            <p v-show="false">{{getzipcode}}</p>

        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                chartNoDataShow: false, //判断是否有无数据
                mom: '', //环比
                yoy: '', //同比
                qoq: '', //季度环比增幅
                zri: '', //平均每月租金
                zri_record_cnt: '', //租金采样个数
                isHouseTypeShow: true, //判断是否符合当前房源的房源类型，符合则展示，不符合则隐藏

            }
        },
        computed: {
            //房源详情页图表使用——本房源所在邮zipcode
            getzipcode() {
                if(this.$store.getters.get_houseDetailsZipcode){
                    //判断对象是否为空
                    if(Object.keys(this.$store.getters.get_houseDetailsBasicInfo).length != 0){
                        if((this.$store.getters.get_houseDetailsBasicInfo.type).toLowerCase() == 'condo'
                            || (this.$store.getters.get_houseDetailsBasicInfo.type).toLowerCase() == 'co-op'
                            || (this.$store.getters.get_houseDetailsBasicInfo.type).toLowerCase() == 'multi'){
                            this.isHouseTypeShow = true;
                            // 获取多家庭公寓中位租金同比环比增幅数据
                            this.get_Zip_Zri_MultiFamilyResidenceRental_Summary();
                        }else{
                            this.isHouseTypeShow = false;
                        }
                    }
                }
                return this.$store.getters.get_houseDetailsZipcode
            },

        },
        created() {
        },
        mounted() {
        },
        methods: {
            //获取多家庭公寓中位租金同比环比增幅数据
            get_Zip_Zri_MultiFamilyResidenceRental_Summary() {
                this.$get('/analysis/zri/80/'+ this.$store.getters.get_houseDetailsZipcode).then(res => {
                    if (res.status == 0) {
                        if(res.data == null){
                            this.chartNoDataShow = true;
                            this.$refs.Zip_Zri_MultiFamilyResidenceRental_Summary_NoData.innerText = '暂未查询到数据！';
                        }else{
                            this.chartNoDataShow = false;
                            this.mom = res.data.mom ? (res.data.mom * 100).toFixed(2) +'%' : 0;
                            this.yoy = res.data.yoy ? (res.data.yoy * 100).toFixed(2) +'%' : 0;
                            this.qoq = res.data.qoq ? (res.data.qoq * 100).toFixed(2) +'%' : 0;
                            this.zri = res.data.zri;
                            this.zri_record_cnt = res.data.zri_record_cnt;
                        }
                    } else {
                        this.chartNoDataShow = true;
                        this.$refs.Zip_Zri_MultiFamilyResidenceRental_Summary_NoData.innerText = '暂未查询到数据！';
                    }
                });
            },
        },
        components: {}
    }
</script>

<style scoped lang="less" type="text/less">
</style>
